#pragma once

#include "net_common.h"
#include <set>

class session;

class tcp_server :
    public std::enable_shared_from_this<tcp_server>,
    private boost::noncopyable {
public:
    tcp_server(boost::asio::io_context &io_context, const tcp::endpoint &endpoint)
        : acceptor_(io_context, endpoint)
    {

    }

    int start()
    {
        do_accept();
        return NET_EC_OK;
    }

private:
    void do_accept();

    tcp::acceptor acceptor_;
    std::set<std::shared_ptr<session>> sessions_;
};
